package com.quanquan.service.impl;

import com.quanquan.entity.StudentLesson;
import com.quanquan.repository.StudentInfoRepository;
import com.quanquan.repository.StudentLessonRepository;
import com.quanquan.service.StudentInfoService;
import com.quanquan.service.StudentLessonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class StudentLessonServiceImpl implements StudentLessonService {

    @Autowired
    private StudentLessonRepository studentLessonRepository;

    public void save(StudentLesson studentLesson) {
        studentLessonRepository.save(studentLesson);
    }

    @Override
    public StudentLesson findById(Long id){
        return studentLessonRepository.findById(id);
    }
    @Override
    public StudentLesson findByStudentId(Long studentId) {
        return studentLessonRepository.findByStudentId(studentId);
    }

    public Long countByGradeAndLessonId(String grade, Long lessonId) {
        return studentLessonRepository.countByGradeAndLessonId(grade, lessonId);
    }

    public List<StudentLesson> findByLessonIdAndGrade(Long id, String grade) {
        return studentLessonRepository.findByLessonIdAndGrade(id, grade);
    }

    public List<StudentLesson> findByLessonId(Long lessonId) {
        return studentLessonRepository.findByLessonId(lessonId);
    }

    public List<StudentLesson> findByStudentClass(String studentClass) {
        return studentLessonRepository.findByStudentClass(studentClass);
    }
}


